
package com.example.tests3;


import org.junit.*;
import static org.junit.Assert.*;

import com.example.pages.UserPage;

public class CreateUser extends TestBase {

  @Test
  public void createNewUser(){
	UserPage userPage = goToMainPage()
       .loginWithValidCredentials("admin", "admin")
       .goToUserManagementConsole();
       
	   SortedListOf<User> oldUserList = userPage.getUsers();
	
	   User user = new User()
	      .withName("user7").withEmail("user7@mail.ru").withPassword("user7");
       
	  
	   
       if(oldUserList.contains(user)){
    	   userPage.deleteUser(user);
    	   oldUserList = userPage.getUsers();
       }
       
       userPage.createNewUser(user);
       
       SortedListOf<User> newUserList = userPage.getUsers();
       
       assertEquals(newUserList,oldUserList.withAdded(user));
       
  }
      
        
}
